package com.briup.day13;

/**
 * @author ThinkBook
 */
public class Test04_Ball {
    public static void main(String[] args) {
        //1.创建游戏对象
        Game game = new Game();

        //2.创建篮球对象，然后开始游戏
        BasketBall basketBall = new BasketBall();
        game.start(basketBall);

        //3.创建足球对象，然后开始游戏
        Football football = new Football();
        game.start(football);

        //第三步：创建乒乓球对象，借助Game对象开始游戏
        PingPang pang = new PingPang();
        game.start(pang);
    }
}
//篮球类
class BasketBall {
    public void play() {
        System.out.println("开始篮球游戏...");
    }
}

//足球类
class Football {
    public void play() {
        System.out.println("开始足球游戏...");
    }
}

//定义游戏类
class Game {
    //启动篮球游戏
    public void start(BasketBall basketBall) {
        basketBall.play();
    }

    //启动足球游戏
    public void start(Football football) {
        football.play();
    }

    //启动乒乓球游戏
    public void start(PingPang pang) {
        pang.play();
    }
}
//1.新增 乒乓球类
class PingPang {
    public void play() {
        System.out.println("开始乒乓球游戏...");
    }
    //2.在Game类新增start方法，去启动乒乓球游戏
    public void start(PingPang pang) {
        pang.play();
    }
}

